package args

import (
	"flag"
	"os"
)

var (
	showHelp    bool
	showVersion bool
	ConfigPath  string
)

func init() {
	//参数配置
	//app, _ := filepath.Abs(os.Args[0])
	//ext := filepath.Ext(os.Args[0])
	//替换后缀名.exe为.yaml
	cfg := "config.yml"

	//log.Println("app.path", app)
	flag.BoolVar(&showVersion, "v", false, "show version")
	flag.BoolVar(&showHelp, "h", false, "show help")
	flag.StringVar(&ConfigPath, "c", cfg, "Configure path")
}

func Parse() {
	flag.Parse()
	if showHelp {
		flag.Usage()
		os.Exit(0)
	}
	if showVersion {
		os.Exit(0)
	}
}
